﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenExpressApp.MetaAttribute;
using Csla.Wpf;
using OpenExpressApp.Command;
using Csla.Core;
using System.ComponentModel;
using System.Windows;
using OpenExpressApp.Template;
using OpenExpressApp.Types;
using Csla;
using OpenExpressApp.WPF.Controls;
using System.Collections.ObjectModel;
using log4net;
using System.Collections;
using OpenExpressApp.MetaModel;
using Avalon.Windows.Controls;
using OpenExpressApp.WPF.Templete;
using OpenExpressApp.Module;
using OpenExpressApp.Module.WPF;
using System.Windows.Controls;
using Ricciolo.Controls;
using System.Reflection;
using System.Windows.Markup;
using System.Diagnostics;
using AvalonDock;
using OpenExpressApp.Module.WPF.Editors;
using Csla.OpenExpressApp;

namespace OpenExpressApp.WPF.Command
{
    /// <summary>
    /// 保存整个列表
    /// </summary>
    [Command(CommandNames.Save_List, ImageName = "Save.bmp", Label = "保存", ToolbarType = ToolbarType.Main, ModuleType = ModuleType.List, ToolTip = "保存记录")]
    public class SaveListCommand : WPFViewCommand
    {
        public override bool CanExecute(ObjectView view)
        {
            return (null != view.CurrentObject) && ((view.Data as ITrackStatus).IsValid) && ((view.Data as ITrackStatus).IsDirty);
        }
        public override void Execute(ObjectView view)
        {
            var savable = view.Data as ISavable;
            view.Data = savable.Save();
        }
    }
}
